import {
	request
} from '@/utils/request'

export default {
	// 发送消息
	sendMessage(data) {
		console.log('API request data:', data);
		return request({
			url: 'http://113.45.222.55:8081/api/chat/send',
			method: 'POST',
			data
		})
	},

	// 获取聊天记录
	getMessages(deviceId, page = 1, size = 20) {
		return request({
			url: 'http://113.45.222.55:8081/api/chat/messages',
			method: 'GET',
			params: {
				deviceId,
				page,
				size
			}
		})
	},

	// 删除消息
	deleteMessage(messageId) {
		return request({
			url: `http://113.45.222.55:8081/api/chat/message/${messageId}`,
			method: 'DELETE'
		})
	},

	// 清空聊天记录
	clearChat(deviceId) {
		return request({
			url: `http://localhost:8081/api/chat/clear/${deviceId}`,
			method: 'DELETE'
		})
	}
}